package com.iptv.grape.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.iptv.grape.BaseActivity;
import com.iptv.grape.util.AppLog;

public abstract class BaseFrgmt extends Fragment {
    private String thisName = this.getClass().getSimpleName();
    protected BaseActivity mActivity;
    protected LayoutInflater inflater;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if(null == context){
            mActivity = (BaseActivity) this.getActivity();
        }else if(context instanceof FragmentActivity){
            mActivity = (BaseActivity) context;
        }else{
            mActivity = (BaseActivity)this.getActivity();
        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.inflater = inflater;
        return inflater.inflate(layoutId(),container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view,savedInstanceState);
    }
    protected  abstract  int layoutId();
    protected  abstract  void initView(@NonNull View view, @Nullable Bundle savedInstanceState);



    @Override
    public void onResume() {
        super.onResume();
        AppLog.getCurLog().e("frgmt=====>"+thisName);
    }
}
